Remove /local when xenstored starts. This stops stale data affecting the
authoremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Thu, 1 Dec 2005 03:32:39 +0000 (03:32 +0000)
committeremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Thu, 1 Dec 2005 03:32:39 +0000 (03:32 +0000)
system immediately after reboot.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
tools/xenstore/xenstored_core.c

index b088bed6254c7f505934bf2019c46f00224b3919..012a4201977e76fca46c5b899b4dc25c665ba094 100644 (file)
@@ -1009,6 +1009,15 @@ static int _rm(struct connection *conn, struct node *node, const char *name)
 }
 
 
+static void internal_rm(const char *name)
+{
+       char *tname = talloc_strdup(talloc_autofree_context(), name);
+       struct node *node = read_node(NULL, tname);
+       if (node)
+               _rm(NULL, node, tname);
+}
+
+
 static void do_rm(struct connection *conn, const char *name)
 {
        struct node *node;
@@ -1417,7 +1426,24 @@ static void setup_structure(void)
        tdbname = talloc_strdup(talloc_autofree_context(), xs_daemon_tdb());
        tdb_ctx = tdb_open(tdbname, 0, TDB_FLAGS, O_RDWR, 0);
 
-       if (!tdb_ctx) {
+       if (tdb_ctx) {
+               /* XXX When we make xenstored able to restart, this will have
+                  to become cleverer, checking for existing domains and not
+                  removing the corresponding entries, but for now xenstored
+                  cannot be restarted without losing all the registered
+                  watches, which breaks all the backend drivers anyway.  We
+                  can therefore get away with just clearing /local and
+                  expecting Xend to put the appropriate entries back in.
+
+                  When this change is made it is important to note that
+                  dom0's entries must be cleaned up on reboot _before_ this
+                  daemon starts, otherwise the backend drivers and dom0's
+                  balloon driver will pick up stale entries.  In the case of
+                  the balloon driver, this can be fatal.
+               */
+               internal_rm("/local");
+       }
+       else {
                tdb_ctx = tdb_open(tdbname, 7919, TDB_FLAGS, O_RDWR|O_CREAT,
                                   0640);
                if (!tdb_ctx)